<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>02-vue组件</title>
        <!-- 引入Vue -->
        <script type="text/javascript" src="../js/vue.js"></script>
    </head>
    <body>
        <!-- 准备好一个容器-->
        <div id="app">
           <Student />
        </div>
    </body>

    <script type="text/javascript">

        // 创建组件 
        let Student = Vue.extend({
            template: `
                <div>
                    <h1>{{uname}}</h1>
                    <h1>{{age}}</h1>
                    <h1>{{sex}}</h1>
                    <button @click="addAge">长大一岁</button>
                </div>
            `,
            data(){
                return{
                    uname: "小溜",
                    age: 18,
                    sex: "男"
                }
            },
            methods:{
                addAge(){
                    this.age++
                }
            }
        })
        
        new Vue({
            el: "#app",
            // 注册组件
            components:{
                Student
            }
        })
        
    </script>
</html>